package hng.exception;

import hng.enums.BizCodeEnum;
import lombok.Data;
@Data
public class BizException extends RuntimeException {

    private int code;

    private String msg;

    public BizException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    /**
     * 处理BizCodeEnum异常
     */
    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
    }

    public BizException(String msg) {
        super(msg);
        this.code = -1;
        this.msg = msg;
    }
}
